Skip to main content

SetColor

Sets the text color to the current text Range in the RGB format.

Syntax

expression.SetColor(r, g, b, isAuto);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
rRequiredbyteRed color component value.
gRequiredbyteGreen color component value.
bRequiredbyteBlue color component value.
isAutoOptionalbooleanfalseIf this parameter is set to "true", then r,g,b parameters will be ignored.

Returns

ApiRange | null

Example

This example sets the text color to the text Range in the RGB format.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = doc.GetRange(0, 24);
range.SetColor(255, 111, 61);